package com.ocm.tourism.core.domain;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.TableGenerator;

import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.springframework.beans.factory.annotation.Configurable;

@Entity
@Configurable
public class AttractionCatalogue {

   @ManyToOne
   private Catalogues catalogues;

   @ManyToOne
   private Catalogues linkedCatalogue;

   public String toString() {
      return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
   }

   public Catalogues getCatalogues() {
      return catalogues;
   }

   public void setCatalogues(Catalogues catalogues) {
      this.catalogues = catalogues;
   }

   public Catalogues getLinkedCatalogue() {
      return linkedCatalogue;
   }

   public void setLinkedCatalogue(Catalogues linkedCatalogue) {
      this.linkedCatalogue = linkedCatalogue;
   }

   @Id
   @GeneratedValue(strategy=GenerationType.TABLE,generator="GEN_ATTRACCATA")
   @TableGenerator(name = "GEN_ATTRACCATA", table = "SEQUENCE_LIST", allocationSize = 1, initialValue = 1, pkColumnName = "NAME", valueColumnName = "NEXT_SEQUENCE", pkColumnValue = "ATTRACCATA")
   private Long id;

   public Long getId() {
      return this.id;
   }

   public void setId(Long id) {
      this.id = id;
   }


   @Override
   public boolean equals(Object obj) {
      AttractionCatalogue attractionBusiness = (AttractionCatalogue) obj;
      boolean result = (attractionBusiness.getCatalogues().getId() == catalogues.getId() && attractionBusiness.getLinkedCatalogue().getId() == linkedCatalogue.getId()); 
      return result;
   }
}
